import java.math.BigDecimal;

/**
 * CheckingAccount inherits from Account and is
 * unremarkable except that it can be linked to a 
 * DebitCard, which also contains a reference back to it.
 * 
 * @author svenb
 *
 */
public class CheckingAccount extends Account
{
	public DebitCard debitCard;
	public static BigDecimal debitRate = new BigDecimal("4.7");
	
	public CheckingAccount(Customer acctCustomer)
	{
		super(acctCustomer);
	}
	
	public CheckingAccount(int accountNumber)
	{
		super(accountNumber);
	}
	
	/**
	 * cost is 1 by default.
	 * This subtracts 1, then further subtracts 4.7% of the principal
	 * in the account. Ouch!
	 * 
	 * An actual bank would probably send that subtraction in to some other
	 * account, but in this example it just goes away.
	 */
	public void determineCosts()
	{
		balance = balance.subtract(costs);
		if(balance.compareTo(new BigDecimal(0)) == 1)
		{
			balance = balance.subtract((balance.multiply(debitRate).divide(new BigDecimal(100))));
		}
	}

	/**
	 * This calls print(String) from the superclass.
	 * The only difference between print for Savings and Checking
	 * is the word "Savings" and "Checking" which appears once, 
	 * so it gets passed in.
	 */
	public void print()
	{
		super.print("Checking");
	}
			
	public DebitCard getDebitCard(){
		return debitCard;
	}
	
	public void setDebitCard(DebitCard accountCard){
		debitCard = accountCard;
	}
	
	/**
	 * This curious override of equals is never called,
	 * but has been thoroughly tested.
	 */
	public boolean equals(Object o)
	{
		if(accountNumber == ((CheckingAccount)o).getAccountNumber())
			return true;
		else
			return false;
	}
}
